﻿using Microsoft.Extensions.Logging;
using Quartz;
using System;
using System.IO;
using System.Threading.Tasks;

namespace WorkerService.Job.Test
{

    [DisallowConcurrentExecution]
    public class HelloTestJob2 : IJob
    {
        private readonly ILogger<HelloTestJob2> _logger;


        public HelloTestJob2(ILogger<HelloTestJob2> logger)
        {
            _logger = logger;

        }

        public Task Execute(IJobExecutionContext context)
        {
            FileStream stream = new FileStream(@"d:\aa1.txt", FileMode.Create);//fileMode指定是读取还是写入
            StreamWriter writer = new StreamWriter(stream);
            writer.WriteLine("123456aaa" + DateTimeOffset.Now);//写入一行，写完后会自动换行
            writer.Write("abc");//写完后不会换行
            writer.WriteLine("ABC");
            writer.Close();//释放内存
            stream.Close();//释放内存

            return Task.CompletedTask;
        }
    }



}
